Casper CBC: minimal implementation design
Note
justification is a mapping from validator to (the hash of)latest message from the validator.
some kind of signature of validator is needed.
For LMD Ghost, message should include validators' weight when the estimate was made.v
minimal structure
Block(ConsensusValue)
fields
parent: int
the hash of parent block
hash: int
Justification
fields
inner: Dict[Validator, int]
mapping from validator to the hash of latest message from the validator.
Message
fields
sender: Validator
estimate: ConsensusValue
justification: Justification
hash: int
State
fields
last_justified_estimate: ConsensusValue
message_history: Dict[Validator, List[Message]]
mapping from validator to its message list
children: Dict[Block, List[Block]]
blockchain protocol specific state
methods
public
validate(message): bool
detect invalid or equivocating message
add_message(message)
justification(): Justification
Validator
fields
name: str
weight: float
state: State
methods
public
receive_message(message: Message)
self.state.validate(message)
self.safety(message)
self.state.add_message(message)
create_message(): Message
private
estimate(): ConsensusValue
BlockEstimator().estimate(state: State)
justification(): Justification
safety(message: Message): float
CliqueOracle().check_estimate_safety(self.state, message)
CliqueOracle(SafetyOracle)
methods
check_estimate_safety(state: State, message: Message): float
BlockEstimator(Estimator)
methods
estimate(state: State) -> ConsensusValue
do LMD Ghost